 *Author AA
*Date 06/03/2025 


clear all


** Conditional Path Structure
*Ashani's Paths

if "`c(username)'" == "ashaniamarasinghe" & "`c(os)'"=="MacOSX" {
	global mainpath "/Users/ashaniamarasinghe/Dropbox/Youtube"
	}

if "`c(username)'" == "aama7224" & "`c(os)'"=="MacOSX" {
	global mainpath "/Users/aama7224/Dropbox/Youtube"
	}



global data "empirics/analysis/data"
global fig "empirics/analysis/fig"
global tab "empirics/analysis/tab"
global est "empirics/analysis/est"



cd $mainpath



use $data/gid_month_panel.dta, clear

*collapsing at gid level

collapse (sum) AC_total_fatalities UCDP_total_fatalities crime_count (mean) var1pred_idw_pop_w_std AC_total_fatalities_pop_w crime_count_pop_w gid_pop pop_share, by (gid _ID)

colorpalette HSV heat, n(6) nograph reverse
local colors `r(p)'
spmap var1pred_idw_pop_w using $raw/priogrid_mex/priogrid_mex_coordinates, ///
 id(_ID) clm(q)  fcolor("`colors'") ///
 ocolor(gs15 ..) osize(0.02 ..) ///
ndfcolor(white) ndocolor(gs15 ..) ndsize(0.02 ..) ndlabel("No data") ///
 polygon(data($raw/priogrid_mex/priogrid_mex_coordinates) ocolor(gs8) osize(0.03) legenda(off) ) ///
 legend(pos(7) size(3) )  legstyle(2) 
 graph export $fig/Figure_5A.png, as(png) replace


 
 
 colorpalette HSV heat, n(6)  nograph reverse
local colors `r(p)'
spmap AC_total_fatalities_pop_w using $raw/priogrid_mex/priogrid_mex_coordinates, ///
 id(_ID) clm(q)  fcolor("`colors'") ///
 ocolor(gs15 ..) osize(0.02 ..) ///
ndfcolor(white) ndocolor(gs15 ..) ndsize(0.02 ..) ndlabel("No data") ///
 polygon(data($raw/priogrid_mex/priogrid_mex_coordinates) ocolor(gs8) osize(0.03) legenda(off) ) ///
 legend(pos(7) size(3) )  legstyle(2) 
 graph export $fig/Figure_5B.png, as(png) replace


 
 colorpalette HSV heat, n(6)  nograph reverse
local colors `r(p)'
spmap crime_count_pop_w using $raw/priogrid_mex/priogrid_mex_coordinates, ///
 id(_ID) clm(q) fcolor("`colors'") ///
 ocolor(gs15 ..) osize(0.02 ..) ///
ndfcolor(white) ndocolor(gs15 ..) ndsize(0.02 ..) ndlabel("No data") ///
 polygon(data($raw/priogrid_mex/priogrid_mex_coordinates) ocolor(gs8) osize(0.03) legenda(off) ) ///
 legend(pos(7) size(3) )  legstyle(2) 
 graph export $fig/Figure_5C.png, as(png) replace

 
 
 gen ln_gid_pop=ln(0.1+gid_pop)
 
 colorpalette HSV heat, n(6)  nograph reverse
local colors `r(p)'
spmap ln_gid_pop using $raw/priogrid_mex/priogrid_mex_coordinates, ///
 id(_ID) clm(q) fcolor("`colors'") ///
 ocolor(gs15 ..) osize(0.02 ..) ///
ndfcolor(white) ndocolor(gs15 ..) ndsize(0.02 ..) ndlabel("No data") ///
 polygon(data($raw/priogrid_mex/priogrid_mex_coordinates) ocolor(gs8) osize(0.03) legenda(off) ) ///
 legend(pos(7) size(3) )  legstyle(2) 
 graph export $fig/Figure_A4.png, as(png) replace


 
 
 